package com.example.demo.day0220;
public class SprinklerSystem {
        private String valve1,valve2,valve3,valve4;
        private WaterSource source=new WaterSource();//复用Watersource类的代码
        private int i;
        private  float f;
        public String toString(){//创建一个将参数转化为字符串的静态的方法
            return
                    "valve1="+valve1+" "+
                            "valve2="+valve2+" "+
                            "valve3="+valve3+" "+
                            "valve4="+valve4+" \n"+
                            "i="+i+""+"f="+f+" "+
                            "source="+source;//valve1,valve2,valve3,valve4,未被赋值，且类型为引用类型string，所以输出null
        }
        public static void main(String[] args){
            SprinklerSystem sprinklers=new SprinklerSystem();//执行上面创建的toString（）方法
            System.out.println(sprinklers);
        }
    }

